﻿using Microsoft.AspNetCore.Mvc;
using studentSubsidy.Dao;
using studentSubsidy.Service;
using studentSubsidy.Entity;
using studentSubsidy.Entity.Home;

namespace studentSubsidy.Controllers
{
    [ApiController]
    [Route("api/home/[Action]")]
    public class HomeController : Controller
    {
        private HomeService _homeService = new HomeService();

        //获取主页轮播图接口
        [HttpPost(Name = "carousel")]
        public Entity.Result Carousel()
        {
            return _homeService.GetCarousel();
        }
        
        [HttpPost(Name = "getPromoProject")]
        public Result GetPromoProject([FromBody]CategoryQuery categoryQuery)
        {
            return _homeService.GetProjectByCategory(categoryQuery.category_id);
        }
        
        [HttpPost(Name = "getCategory")]
        public Result GetCategory()
        {
            return _homeService.GetCategory();
        }

        [HttpPost(Name = "getAllProject")]
        public Result GetAllProject([FromBody] ProjectQuery projectQuery)
        {
            return _homeService.GetAllProject(projectQuery);
        }
        
        [HttpPost(Name = "getProjectByCategory")]
        public Result GetProjectByCategory([FromBody] ProjectQuery projectQuery)
        {
            return _homeService.GetProjectByCategoryPage(projectQuery);
        }
    }
}